package com.gcu.drivingschool.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;


/**
 * 统一返回结果
 * @author zzr
 * @create 2024-03-02-16:43
 */
@Data
@Schema(description = "统一返回结果")
public class Result {
    /** 状态码 */
    @Schema(description = "状态码")
    private Integer code;

    /** 返回消息 */
    @Schema(description = "消息")
    private String msg;

    /** 数据对象 */
    @Schema(description = "数据")
    private Object data;

    public Result() {
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(Object data){
        return new Result(200,"操作成功",data);
    }

    public static Result success(String mess){
        return new Result(200,mess);
    }

    public static Result success(){
        return new Result(200,"操作成功");
    }

    public static Result success(String mess,Object data){
        return new Result(200,mess,data);
    }

    public static Result fail(String msg){
        return new Result(400,msg);
    }

    public static Result fail(){
        return new Result(400,"操作失败");
    }

    public static Result fail(Integer code, String mess, Object data) {
        return new Result(code,mess,data);
    }
}
